package com.evaluationSystem.util;

import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
import org.apache.poi.ss.usermodel.Sheet;

import java.util.List;

/**
 * @ClassName ExcelWidthStyleStrategy
 * @Description 自动设置列宽
 * @Author yinzhenxing
 * @Date 2023/1/6 18:25
 **/
public class ExcelWidthStyleStrategy extends AbstractColumnWidthStyleStrategy {

    protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head,
                                  Integer relativeRowIndex, Boolean isHead) {
        // 简单设置
        Sheet sheet = writeSheetHolder.getSheet();
        sheet.setColumnWidth(cell.getColumnIndex(), 5000);
    }
}
